package com.imooc.VO;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * http请求的返回的最外层对象
 * @author liuhuan
 * @date 2018/7/5 11:13
 * @description
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO<T> {
    /**
     * 错误码
     */
    private int code;
    /**
     * 提示信息
     */
    private String msg;
    /**
     * 具体数据
     */
    private  T data;

    public static <T> ResultVO<T> success(T data){
        ResultVO<T> result=new ResultVO<T>(0,"success",data);
        return result;
    }
    public static <T> ResultVO<T> success(){

        return success(null);
    }

    public static <T>  ResultVO<T> fail(String msg){
        ResultVO<T> result=new ResultVO<T>(1,msg,null);
        return result;
    }
    public static <T>  ResultVO<T> fail(Integer code,String msg){
        ResultVO<T> result=new ResultVO<T>(code,msg,null);
        return result;
    }
}
